package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.StrategyComment;
import cn.wolfcode.trip.base.domain.StrategyLike;
import cn.wolfcode.trip.base.mapper.StrategyCommentMapper;
import cn.wolfcode.trip.base.mapper.StrategyLikeMapper;
import cn.wolfcode.trip.base.service.IStrategyLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StrategyLikeServiceImpl implements IStrategyLikeService {
    @Autowired
    private StrategyLikeMapper mapper;
    @Autowired
    private StrategyCommentMapper commentMapper;


    @Override
    public void delete(Long userId, Long strategyId) {
        commentMapper.updateLikeCount(strategyId,-1);
        mapper.delete(userId,strategyId);
    }

    @Override
    public void saveOrUpdate(StrategyLike strategy) {
            mapper.insert(strategy);
            commentMapper.updateLikeCount(strategy.getStrategyId(),1);



    }

    @Override
    public Integer selectLike(Long userId, Long strategyId) {

        return mapper.selectLike(userId,strategyId);
    }


}
